home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _F117EE8C47064BBE8E35C2DD2454C919 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.7 KB  |  46 lines

  1.       #include "../CGVPMacro.csi"
  2.  
  3.       PS20Only
  4.  
  5.       MainInput { uniform sampler2D baseMap : texunit0,
  6.                   uniform sampler2D bumpMap : texunit1,
  7.                   uniform samplerCUBE normCubeMapLV : texunit2,
  8.                   uniform samplerCUBE normCubeMapHA : texunit3,
  9.                   uniform samplerCUBE projMap : texunit4,
  10.                   uniform sampler2D attenMap : texunit5,
  11.                   uniform float4 Diffuse,
  12.                   uniform float4 Specular }
  13.       DeclarationsScript
  14.       {
  15.         OUT_T0_T1_T2_T3_T4_T5_C0
  16.         FOUT
  17.       }
  18.       CoreScript
  19.       {
  20.         // load the decal
  21.         half4 decalColor = tex2D(baseMap, IN.Tex0.xy);
  22.         // load the bump normal
  23.         float4 bumpNormal = tex2D(bumpMap, IN.Tex1.xy)*2-1;
  24.         // load the projector filter map
  25.         half4 projColor = texCUBE(projMap, IN.Tex4.xyz);
  26.         half a = IN.Color.b*2-1;
  27.         half atten = saturate(a * -a + (1-tex2D(attenMap, IN.Tex5.xy).b));
  28.  
  29.         // Light vector from normalization cube-map
  30.         float4 lVec = texCUBE(normCubeMapLV, IN.Tex2.xyz)*2-1;
  31.         // Half angle vector from normalization cube-map
  32.         float4 hVec = texCUBE(normCubeMapHA, IN.Tex3.xyz)*2-1;
  33.         
  34.         float NdotL = saturate(dot(lVec.xyz, bumpNormal.xyz));
  35.         float NdotH = saturate(dot(hVec.xyz, bumpNormal.xyz));
  36.         float  specVal = pow(NdotH,8);
  37.         half3 proj = atten * projColor.xyz;
  38.         half3 dif = (decalColor.xyz * NdotL * Diffuse.xyz * proj.xyz) * 2;
  39.         half3 spec = (specVal * decalColor.w * Specular.xyz * proj.xyz) * 2;
  40.  
  41.         // finally add them all together
  42.         OUT.Color.xyz = dif + spec;
  43.         OUT.Color.w = Diffuse.w;
  44.       }
  45.  
  46.